from model import model
from vo.ViewBaseObject import ViewBaseObject

#博客内容视图
class BlogViewObject(ViewBaseObject):
    def __init__(self,aid=None,url=None):
        if not aid == None:
            arts = model.article.objects(id=aid)
        if not url == None :
            arts = model.article.objects(url=url)
        if len(arts) > 0:
            self.art = arts.get()
            self.view = True
        else:
            self.view = False
        super().__init__()
#从id找博客
def build(aid)->BlogViewObject:
    return BlogViewObject(aid=aid)
#从url找博客
def buildurl(url)->BlogViewObject:
    return BlogViewObject(url=url)